<?php
declare (strict_types = 1);

namespace app\admin\controller;

use bbweb\basic\BaseController;
use think\facade\Db;
use think\Request;

class Citys extends BaseController
{
    /**
     * 获取城市联动
     */
    public function getCity(Request $req) {
        if ($req->isPost()) {
            $id = $req->param('id/d');
            if (empty($id)) {
                $this->error('很抱歉、参数错误！');
                exit;
            }
            $citys = Db::name('citys')->where('parent_id','=',$id)->field('id,name')->order('id asc')->select();
            return json(['code'=>1,'data'=>$citys]);
        }
        $this->error('很抱歉、参数错误！');
    }
}
